#include <iostream>
#include <chrono>
#include <random>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#define VNAME(name) (#name)
#define debug(x) {std::cout << " (" << VNAME(x) << ": " << (x) << ")\n";}
#define F_(n) cout << fixed << setprecision(n)
using namespace std;
typedef long long LL;
const int N = 1e3 + 5;
const int MOD = 1e9 + 7;
mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
int _Flag;
/*static int _ = [](){
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    return 0;
}();//*/
int w[N][5];
void solve() {
    int n, pd[5] = {0};
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i) {
        for (int j = 0; j < 5; ++ j) {
            scanf("%d", &w[i][j]);
            pd[j] += w[i][j];
        }
    }
    for (int i = 0; i < 5; ++ i) {
        for (int j = i + 1; j < 5; ++ j) {
            if (pd[i] >= n / 2 && pd[j] >= n / 2) {
                bool flag = true;
                for (int k = 1; k <= n; ++ k) {
                    if (!w[k][i] && !w[k][j]) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    puts("YES");
                    return ;
                }
            }
        }
    }
    puts("NO");
}
signed main() {
    #ifndef ONLINE_JUDGE
		_Flag = false; //freopen("C:\\Users\\lenovo\\Desktop\\in.in", "r", stdin);
	#endif
    int t;
    scanf("%d", &t);
    while (t --) {
        solve();
    }
    return 0;
}